package cn.szzsi._sys;

import cn.szzsi.common.model.Member;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;

/**
 * Created by zhengy on 2017/12/7.
 */
public class CustomerController extends Controller{

    public void list(){
        render("member_list.html");
    }

    public void ajaxlist(){
        int pageNumber=getParaToInt("pageNumber", 1);//第几页,默认1
        int pageSize=getParaToInt("pageSize", 10);//每页的数量,默认10
        String starttime=getPara("starttime");
        String endtime=getPara("endtime");
        String phone=getPara("phone");
        String sql=" from mall_member m where 1=1";

        if(StrKit.notBlank(starttime)){
            sql+=" and m.createDate>='"+starttime+"'";
        }
        if(StrKit.notBlank(endtime)){
            sql+=" and m.createDate<='"+endtime+"'";
        }
        if(StrKit.notBlank(phone)){
            sql+=" and m.phone like '%"+phone+"%'";
        }
        sql+=" order by createDate desc";
        Page<Member> page=Member.dao.paginate(pageNumber,pageSize,"select *",sql);
        renderJson(page);


    }
}
